﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace CPPEI.Coolzon.Designer.Views
{
    public partial class DesignData
    {
        /// <summary>
        /// 获取组件相对于设计器画布的绝对位置
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public Point GetAbsoluteOffset(CPPEI.Coolzon.UI.Part part)
        {
            return part.TranslatePoint(new Point(0, 0), this._ctlRenderPanel);
        }

        /// <summary>
        /// 画布上的点转换到组件内部的相对位置
        /// </summary>
        /// <param name="part"></param>
        /// <param name="pointInCanvas"></param>
        /// <returns></returns>
        public Point PointFromSceneToElement(UIElement part, Point pointInCanvas)
        {
            return _ctlRenderPanel.TranslatePoint(pointInCanvas, part);
        }

        /// <summary>
        /// 组件上的相对位置站换到画布上的相对位置
        /// </summary>
        /// <param name="part"></param>
        /// <param name="pointInPart"></param>
        /// <returns></returns>
        public Point PointElementPartToCanvas(UIElement part, Point pointInPart)
        {
            return part.TranslatePoint(pointInPart, this._ctlDesignCanvas);
        }
    }
}
